﻿@{
    ViewBag.Title = "TransitionForm";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}
<script>
    $(function () {
        GetGrid();
    });
    //加载表格
    function GetGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable');
        var queryJson = {
            OrganizeId: ""
        };
        $gridTable.jqGrid({
            url: "../../QualificationManage/Contract/GetTransitionContractBussiness",
            postData: { queryJson: JSON.stringify(queryJson) },
            datatype: "json",
            height: $(window).height() - 120,
            autowidth: true,
            colModel: [
                { label: "承租人", name: "name", index: "name", width: 120, align: "center" },
                { label: "身份证号码", name: "idcard", index: "idcard", width: 200, align: "center" },
                { label: "承租房产", name: "allname", index: "allname", width: 300, align: "left" },
                { label: "合同号", name: "ccode", index: "ccode", width: 150, align: "center" },
                { label: "续租单号", name: "bcode", index: "bcode", width: 150, align: "center" },
                { label: "资格单号", name: "qcode", index: "qcode", width: 150, align: "center" },
                { label: "合同开始日期", name: "begindate", index: "begindate", width: 110, align: "center", formatter: "date", formatoptions: { newformat: 'Y-m-d' } },
                { label: "合同结束日期", name: "enddate", index: "enddate", width: 110, align: "center", formatter: "date", formatoptions: { newformat: 'Y-m-d' } },


            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'ccode',
            sortorder: 'desc',
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        //查询条件
        $("#queryCondition .dropdown-menu li").click(function () {
            var text = $(this).find('a').html();
            var value = $(this).find('a').attr('data-value');
            $("#queryCondition .dropdown-text").html(text).attr('data-value', value); 
        });
        $("#btn_Search").click(function () {
            var queryJson = $("#filter-form").GetWebControls();
            queryJson["OrganizeId"] = "";
            queryJson["Code"] = $("#queryCondition").find('.dropdown-text').attr('data-value') == "Code" ? $("#txt_Keyword").val() : "",
            queryJson["Name"] = $("#queryCondition").find('.dropdown-text').attr('data-value') == "Name" ? $("#txt_Keyword").val() : "",
            //queryJson["Phone"] = $("#queryCondition").find('.dropdown-text').attr('data-value') == "Phone" ? $("#txt_Keyword").val() : "",
             queryJson["IDCard"] = $("#queryCondition").find('.dropdown-text').attr('data-value') == "IDCard" ? $("#txt_Keyword").val() : "",

            $gridTable.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJson) }
            }).trigger('reloadGrid');
            $(".ui-filter-text").trigger("click");
        });
    }




    //新增
    function btn_Add() {
        var CCode = $("#gridTable").jqGridRowValue("ccode");
        if (checkedRow(CCode)) {
            var queryJson = {
                CCode: CCode,
                QCode: $("#gridTable").jqGridRowValue("qcode"),
                BCode: $("#gridTable").jqGridRowValue("bcode")
            };
            $.ConfirmAjax({
                msg: "注：您确认要进行过渡申请操作吗？",
                url: "../../QualificationManage/Contract/CreateTransitionBussiness",
                param: { queryJson: JSON.stringify(queryJson) },
                loading: "正在保存数据...",
                success: function () {

                    $.currentIframe().$("#gridTable").resetSelection();
                    $.currentIframe().$("#gridTable").trigger("reloadGrid");
                    dialogClose();
                }
            });
        }


    }
    function AcceptClick() {
        dialogClose();
    }
</script>

<div class="titlePanel">
    <div class="title-search">
        <div class="toolbar">
            <table>
                <tr>
                    <td>
                        <div id="queryCondition" class="btn-group">
                            <a class="btn btn-default dropdown-text" data-toggle="dropdown">选择条件</a>
                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a data-value="Code">编码</a></li>
                                <li><a data-value="Name">名称</a></li>
                                <li><a data-value="IDCard">身份证号</a></li>
                            </ul>
                        </div>
                    </td>
                    <td style="padding-left: 2px;">
                        <input id="txt_Keyword" type="text" maxlength="20" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
                    </td>
                    <td style="padding-left: 5px;">
                        <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
                    </td>
                    <td style="padding-left: 5px;"><a id="btn_add" class="btn btn-success" onclick="btn_Add();"> <i class="fa fa-plus"></i>&nbsp;创建过渡申请单</a></td>
                </tr>
            </table>

        </div>
    </div>
</div>
<div class="gridPanel">
    <table id="gridTable"></table>
    <div id="gridPager"></div>
</div>
